# 创建人脸集合
face = [{'faceId': '84ab7e2e-3ece-4f49-9d27-35f612013205',
  'faceRectangle': {'top': 429, 'left': 64, 'width': 424, 'height': 424},
  'faceAttributes': {'smile': 0.0,
   'headPose': {'pitch': -16.9, 'roll': -2.6, 'yaw': 4.0},
   'gender': 'male',
   'age': 21.0,
   'facialHair': {'moustache': 0.1, 'beard': 0.1, 'sideburns': 0.1},
   'glasses': 'NoGlasses',
   'emotion': {'anger': 0.0,
    'contempt': 0.0,
    'disgust': 0.0,
    'fear': 0.0,
    'happiness': 0.0,
    'neutral': 0.998,
    'sadness': 0.001,
    'surprise': 0.001},
   'blur': {'blurLevel': 'medium', 'value': 0.3},
   'exposure': {'exposureLevel': 'overExposure', 'value': 0.83},
   'noise': {'noiseLevel': 'low', 'value': 0.13},
   'makeup': {'eyeMakeup': True, 'lipMakeup': True},
   'accessories': [],
   'occlusion': {'foreheadOccluded': False,
    'eyeOccluded': False,
    'mouthOccluded': False},
   'hair': {'bald': 0.05,
    'invisible': False,
    'hairColor': [{'color': 'brown', 'confidence': 0.99},
     {'color': 'red', 'confidence': 0.92},
     {'color': 'blond', 'confidence': 0.32},
     {'color': 'black', 'confidence': 0.19},
     {'color': 'other', 'confidence': 0.19},
     {'color': 'gray', 'confidence': 0.02},
     {'color': 'white', 'confidence': 0.0}]}}},
 {'faceId': 'ed354006-4da6-4f47-b629-9af9f0c0dd07',
  'faceRectangle': {'top': 979, 'left': 475, 'width': 391, 'height': 391},
  'faceAttributes': {'smile': 1.0,
   'headPose': {'pitch': -16.0, 'roll': -23.4, 'yaw': 1.1},
   'gender': 'male',
   'age': 24.0,
   'facialHair': {'moustache': 0.1, 'beard': 0.1, 'sideburns': 0.1},
   'glasses': 'NoGlasses',
   'emotion': {'anger': 0.0,
    'contempt': 0.0,
    'disgust': 0.0,
    'fear': 0.0,
    'happiness': 1.0,
    'neutral': 0.0,
    'sadness': 0.0,
    'surprise': 0.0},
   'blur': {'blurLevel': 'medium', 'value': 0.52},
   'exposure': {'exposureLevel': 'overExposure', 'value': 0.93},
   'noise': {'noiseLevel': 'medium', 'value': 0.31},
   'makeup': {'eyeMakeup': True, 'lipMakeup': True},
   'accessories': [],
   'occlusion': {'foreheadOccluded': False,
    'eyeOccluded': False,
    'mouthOccluded': False},
   'hair': {'bald': 0.03,
    'invisible': False,
    'hairColor': [{'color': 'blond', 'confidence': 1.0},
     {'color': 'gray', 'confidence': 0.59},
     {'color': 'brown', 'confidence': 0.42},
     {'color': 'red', 'confidence': 0.19},
     {'color': 'other', 'confidence': 0.16},
     {'color': 'black', 'confidence': 0.01},
     {'color': 'white', 'confidence': 0.0}]}}},
 {'faceId': '109be2cb-15c3-4d6b-b128-77cbe4265705',
  'faceRectangle': {'top': 648, 'left': 752, 'width': 361, 'height': 361},
  'faceAttributes': {'smile': 0.049,
   'headPose': {'pitch': -26.4, 'roll': -0.5, 'yaw': 2.9},
   'gender': 'male',
   'age': 20.0,
   'facialHair': {'moustache': 0.1, 'beard': 0.1, 'sideburns': 0.1},
   'glasses': 'NoGlasses',
   'emotion': {'anger': 0.029,
    'contempt': 0.01,
    'disgust': 0.012,
    'fear': 0.25,
    'happiness': 0.049,
    'neutral': 0.486,
    'sadness': 0.043,
    'surprise': 0.121},
   'blur': {'blurLevel': 'medium', 'value': 0.53},
   'exposure': {'exposureLevel': 'overExposure', 'value': 0.78},
   'noise': {'noiseLevel': 'medium', 'value': 0.45},
   'makeup': {'eyeMakeup': True, 'lipMakeup': True},
   'accessories': [],
   'occlusion': {'foreheadOccluded': False,
    'eyeOccluded': False,
    'mouthOccluded': False},
   'hair': {'bald': 0.02,
    'invisible': False,
    'hairColor': [{'color': 'blond', 'confidence': 1.0},
     {'color': 'gray', 'confidence': 0.55},
     {'color': 'brown', 'confidence': 0.4},
     {'color': 'other', 'confidence': 0.24},
     {'color': 'red', 'confidence': 0.15},
     {'color': 'black', 'confidence': 0.06},
     {'color': 'white', 'confidence': 0.0}]}}}]

# 创建字典
smile = {}
hairColor = {}
age = {}
gender = {}
glasses = {}

# 添加人脸到字典里面
count = 0
while count < len(face):
    glasses["Person{}".format(count + 1)] = face[count]['faceAttributes']['glasses']
    smile["Person{}".format(count + 1)] = face[count]['faceAttributes']['smile']
    hairColor["Person{}".format(count + 1)] = face[count]['faceAttributes']['hair']['hairColor'][0]['color']
    age["Person{}".format(count + 1)] = face[count]['faceAttributes']['age']
    gender["Person{}".format(count + 1)] = face[count]['faceAttributes']['gender']
    count += 1

# 打印字典
print("眼镜：", glasses)
print("微笑指数：", smile)
print("头发颜色：", hairColor)
print("年龄：", age)
print("性别：", gender)

# 眼镜： {'Person1': 'NoGlasses', 'Person2': 'NoGlasses', 'Person3': 'NoGlasses'}
# 微笑指数： {'Person1': 0.0, 'Person2': 1.0, 'Person3': 0.049}
# 头发颜色： {'Person1': 'brown', 'Person2': 'blond', 'Person3': 'blond'}
# 年龄： {'Person1': 21.0, 'Person2': 24.0, 'Person3': 20.0}
# 性别： {'Person1': 'male', 'Person2': 'male', 'Person3': 'male'}
